package com.oauth.service.twitter;

import com.oauth.service.OAuthDAO;
import com.oauth.service.OAuthService;
import com.oauth.service.OAuthServiceException;
import com.oauth.service.twitter.beans.TwitterServiceBean;

public class TwitterServiceImpl implements OAuthService<TwitterServiceBean> {

	private OAuthDAO<TwitterServiceBean> mTwitterDAO;
	
	@Override
	public void deleteToken(Long memberId) throws OAuthServiceException {
		getTwitterDAO().deleteToken(memberId);
	}

	@Override
	public TwitterServiceBean getToken(Long memberId) throws OAuthServiceException {
		return getTwitterDAO().getToken(memberId);
	}

	@Override
	public TwitterServiceBean persistToken(TwitterServiceBean serviceBean) throws OAuthServiceException {
		if (serviceBean.getMemberId() == null
				|| serviceBean.getAccessToken() == null
				|| serviceBean.getAccessTokenSecret() == null) {
			throw new OAuthServiceException("Parameters are null" + serviceBean);
		}
		return getTwitterDAO().persistToken(serviceBean);
	}

	/**
	 * @return the twitterDAO
	 */
	public OAuthDAO<TwitterServiceBean> getTwitterDAO() {
		return mTwitterDAO;
	}

	/**
	 * @param pTwitterDAO the twitterDAO to set
	 */
	public void setTwitterDAO(OAuthDAO<TwitterServiceBean> pTwitterDAO) {
		mTwitterDAO = pTwitterDAO;
	}

	
	
	
}